/**
 * <p>Copyright: Copyright (c) 2014</p>
 * <p>Company: ---Technology Co. Ltd</p>
 * <p>2014-4-30</p>
 * @author Jan.Zhang
 */
package com.xianl.busiplat.shiro;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.UsernamePasswordToken;


/** 
 * desc:
 * <p>author: Jan.Zhang </p>
 * date: 2014-4-30
 */
public class CaptchaUsernamePasswordToken extends UsernamePasswordToken {

	/**
	 * long:serialVersionUID
	 */
	private static final long serialVersionUID = 357763104115199102L;
	private String captcha;
	private boolean rememberMe;
	
	public CaptchaUsernamePasswordToken() {
		super();
	}
	
	public CaptchaUsernamePasswordToken (String username , String password , boolean rememberMe , String host ,
			String captcha ) {
		super(username, password, rememberMe, host);
		this.captcha = captcha;
		this.rememberMe = rememberMe;
	}
	
	public String getCaptcha(){
		return captcha;
	}
	
	public void setCaptcha(String captcha){
		this.captcha = captcha;
	}
	
	public boolean isRememberMe(){
		return rememberMe;
	}
	
	public void setRememberMe(boolean rememberMe){
		this.rememberMe = rememberMe;
	}
	
	public String getMyHost(){
		String host = StringUtils.trimToEmpty(getHost());
		String[] tmp = host.split("[.]");
		if(tmp.length != 4){
			return "127.0.0.1";
		}else{
			return host;
		}
	}
	
}
